package net.wofly.common.pay.alipay.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */
@Component
@ConfigurationProperties(prefix = "ailpay")
@Data
public class AlipayConfigDev {

//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
    
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2016082100307940";
    
    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCvMlrt3DC9hjGDgh+3mhIJkuOEkRDdSP7z4+EAV8UyshsEiFF6XsZTD/sRQP3iJ9hzmRBr3R2Gn8OE6k69Gzz8YnMuQE6ACi3UrlypIo4Z8rC5GgXqFPC+GrOeTspsMUdc3LTwxaMGeIDn9bFo/YgH0Be4BFwsPC1NsmRqUGy1RVKyuonJneQfCJ00/fXbwYXCTFFDoMxbbWj0brlVrZCWyqAkz+9PEBQh49s1pR82MbZcYGurFO8GgyGVddZaoFjerkvFcF/0FgZbkJ+JsavxbzC/QfC+vZVUeW5lBxcUGPFGzb7IcJHMRQSFfyQERXn6tRmtfTrInMVbz3b5TD5jAgMBAAECggEAdgmMP/P5lseh9oOmUPJqMq8XwUpnvV+f/rxK7Qs1nplnIJ+jnbnbDz2WH6LVKxlDeWboLHQ2n2xms9eVo02FwlmmVsQW36d8B25OmdnhOdRMgvnogDUJmlutJvzY3xo4hXViJ1JRK1vnJeFgXWdrzi/Cu0WcwGTu9Qk7JHH5PAtSc4gDjEV0oWmU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.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIgHnOn7LLILlKETd6BFRJ0GqgS2Y3mn1wMQmyh9zEyWlz5p1zrahRahbXAfCfSqshSNfqOmAQzSHRVjCqjsAw1jyqrXaPdKBmr90DIpIxmIyKXv4GGAkPyJ/6FTFY99uhpiq0qadD/uSzQsefWo0aTvP/65zi3eof7TcZ32oWpwIDAQAB";
    
    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    //public static String notify_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";
    public static String notify_url = "http://114.215.18.58:8080/sale/api/pay/notify4AliPay";
    
    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    //public static String return_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";
    public static String return_url_pc = "http://114.215.18.58:8080//#/information/pay";
    public static String return_url_h5 = "http://114.215.18.58:8080//#/m/account";
    
    // 签名方式
    public static String sign_type = "RSA2";
    
    // 字符编码格式
    public static String charset = "utf-8";
    
    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
    
    // 支付宝网关
    public static String log_path = "E:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
    
    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

